﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace 第三章
{
    public class UserInfo 
    {
        string Name;
        DateTime Birthday;

        public UserInfo(string Name, DateTime Birthday)
        {
            this.Name = Name;
            this.Birthday = Birthday;
        }

        public bool DecideAge() 
        {
            return DateTime.Now.Year - this.Birthday.Year > 18;
        }
    }


    public partial class _3__8 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            string name = this.TXTname.Text;
            DateTime birthday;
            try
            {
                birthday = DateTime.Parse(this.InputBirthday.Value);
            }
            catch (Exception)
            {
                Response.Write("请重新输入年龄！");
                return;
            }
            UserInfo use = new UserInfo(name, birthday);
            if (use.DecideAge())
            {
                Response.Write("您是成人了！");
            }
            else { 
                Response.Write("您还没长大呢！");
            }

        }
    }
}